/********jquery.newtouch.util  start ***********/
/**
 * 自定义部分常用工具方法
 * @author YangKui
 * 使用方式如下：$.util.method
 * 
 * 
 * $.logUtil.save();
 */
;(function($){
	$.util = (function(){
		function get2Length(str) {
			return (str.toString().length == 1 ? "0" + str : str);
		}
		return {
			//返回IE版本
			ieVersion:function(){
                if (window.XMLHttpRequest) { //Mozilla, Safari,IE7 
                    if (!window.ActiveXObject) { // Mozilla, Safari,
                        return "Mozilla";
                    }else{
                        return 'IE7';
                    }
                }  else {
                    return 'IE6';
                }
			},
			isNotEmpty : function(o) {
				return (o && o != "" && o != null && o != "null" && typeof o != "undefined");
			},
			isEmpty : function(o) {
				return (o == "" || o == null || o == "null" || typeof o == "undefined");
			},
			/**
			 * 检测是否为手机号格式 目前只验证是否为1开头的11位数字
			 *
			 * @param str
			 *            要验证的手机号
			 */
			isPhoneNum : function(str) {
				return /^1\d{10}$/.test(str);
			},
			isMoney : function(str) {
				var isMoney = /^(?!0\d)(?!\.)[0-9]+(\.[0-9]{1,2})?$/;
				return isMoney.test(str); // 是否为钱币格式
			},
			/**
			 * 是否为数字
			 *
			 * @param str
			 */
			isNumber : function(str) {
				var vInt = /^\+?[\d]*$/;
				return vInt.test(str);
			},
			isEnglish:function(str){
				var p = /^[a-zA-Z]*$/;
				return p.test(str);
			},
			/**
			 * 是否为大于0的整数
			 *
			 * @param str
			 */
			isPositiveNum : function(str) {
				var positiveNum = /^[1-9]+?[0-9]*$/;
				return positiveNum.test(str);
			},	
			/**
			 * 判断字符串是否在数组中存在
			 *
			 * @param str
			 *            字符串
			 * @param array
			 *            字符串数组	
			 */
			inArray: function(str,array){
				for(i=0;i<array.length;i++){
					if(array[i]==str){
						return true;
					}
				}
				return false;
			},
			/**
			 * 让下拉框显示指定值的下拉列表
			 *
			 * @param selectId
			 *            下拉框ID
			 * @param flag
			 *            比较对象标志 取值:value||text,默认为value
			 * @param value
			 *            要显示的值
			 */
			fireSelect : function(selectId, value, flag) {
				var f = flag || "value";
				$("#" + selectId + " >option").each( function() {
					var val = $(this).val();
					if (f != "value") {
						val = $(this).text();
					}
					val = val || null;
					if (val != null && val == value) {
						$(this).attr("selected", "selected");
						return;
					}
				});
			},
			/**
			 * 获取钱币格式的数字，含两位小数
			 * 四舍五入后取两位小数，不满两位用0补齐
			 */
			getFloatPrice : function(number) {
				if(number==""||number==null||number==undefined){
					return "";
				}
				if(number.toString().indexOf("NaN") > -1){
					return "";
				}
				var number2 = Math.round(number * 100) / 100; // 四舍五入后取两位小数
				number2 = number2.toString();
				if (number2.indexOf(".") > -1) {
					var subNuber = number2.substring(number2.indexOf(".") + 1,
							number2.length);
					if (subNuber.length < 2) {
						number2 = number2 + "0";
					}
				} else {
					number2 = number2 + ".00";
				}
				return number2;
			},
			/**
			 * 获取优惠系数的数字，含两位小数
			 * 四舍五入后取4位小数，不满两位用0补齐
			 */
			getFloatDis : function(number) {
				if(number==""||number==null||number==undefined){
					return "";
				}
				if(number.toString().indexOf("NaN") > -1){
					return "";
				}
				var number2 = Math.round(number * 10000) / 10000; // 四舍五入后取4位小数
				number2 = number2.toString();
				if (number2.indexOf(".") > -1) {
					var subNuber = number2.substring(number2.indexOf(".") + 1,
							number2.indexOf(".") + 5);
//					if (subNuber.length < 2) {
//						number2 = number2 + "0";
//					}
				} else {
					number2 = number2 + ".00";
				}
				return number2;
			},
			/**
			 * 获取去除指定位数的价格
			 * 如：12103 去除百位后是12000
			 * @param price 要去除的价格
			 * @param cutInt 去除的位数，使用100 或1000表示
			 * @return
			 */
			getCutPrice:function(price ,cutInt){
				price*=1;cutInt*=1;
				var cutPrice = price/cutInt/10+"";
				if(cutPrice.indexOf(".")>-1){
					cutPrice = cutPrice.substring(0, cutPrice.indexOf("."));
				}
				var length = 1;
				while(cutInt%10==0){
					cutInt/=10;
					length++;
				}
				for(var i=0 ;i<length;i++){
					cutPrice+="0";
				}
				return cutPrice;
			},
			/**
			 * 将字符串转换为整数
			 * @param {Object} string
			 */
			getNumberFromString : function(string) {
				if (string.indexOf(".") > -1) {
					return string.substring(0, string.indexOf("."));
				} else {
					return string;
				}
			},
			/**
			 * 格式化日期，暂时支持两种格式
			 */
			formatDate : function(date, type) {
				var newDate;
				var styleArray = [ "yyyy-MM-dd", "yyyy-MM-dd HH:ss:mm" ];
				var style = type || "yyyy-MM-dd";
				var pattern = new RegExp("-", "gi");
				if (date instanceof Date) {
					newDate = date;
				} else if (typeof date == "string") {
					newDate = date.replace(pattern, "/");
					if (/[0-9]{4}\/[0-9]{2}\/[0-9]{2}$/.test(newDate)) {
						newDate = newDate.substring(0, 10);
						if (!/[0-9]{4}\/[0-9]{2}\/[0-9]{2}$/.test(newDate)) {
							return date;
						}
					} else if(/[0-9]{4}\/[0-9]{2}\/[0-9]{2}/.test(newDate)){
						newDate = newDate.substring(0, 19);
					}else{
						return date;
					}
				} else {
					$.logUtil.save("非日期格式！");
					return;
				}
				var d = new Date(newDate);
				var index = -1;
				for ( var i = 0; i < styleArray.length; i++) {
					if (styleArray[i] == style) {
						index = i;
						break;
					}
				}
				if (index == -1)
					return date;
				var year = d.getFullYear();
				var month = d.getMonth() + 1;
				var day = d.getDate();
				var hh = d.getHours();
				var ss = d.getMinutes();
				var mm = d.getSeconds();
				var dateStr = date.toLocaleString();
				if (index == 0)
					dateStr = year + "-" + get2Length(month) + "-"
							+ get2Length(day);
				else if (index == 1)
					dateStr = year + "-" + get2Length(month) + "-"
							+ get2Length(day) + " " + get2Length(hh) + ":"
							+ get2Length(ss) + ":" + get2Length(mm);
				return dateStr;

			},
			/**
			 * 为日期添加或减去天数
			 *
			 * @param date
			 *            要进行增减的日期对象，必须是日期对象或日期格式的对象
			 * @param num
			 *            要加减的天数，如果是减去天数，则以-3的方式填写 <code>
			 *  var newDate =  $.util.addDate(new Date(),5);
			 *  var newDate =  $.util.addDate("2010-01-22",-5);// 2010-01-17
			 * </code>
			 */
			addDate : function(date, num) {
				var newDate;
				if (date instanceof Date) {
					var oldDateNum = date.valueOf();
					var newDateNum = getNewDateNum(oldDateNum, num);
					newDate = new Date(newDateNum);
				} else if (typeof date == "string") {
					var pattern = new RegExp("-", "gi");
					date = date.replace(pattern, "/");
					if (!/[0-9]{4}\/[0-9]{2}\/[0-9]{2}/.test(date)) {
						$.logUtil.save("增加天数时：日期格式不正确！");
						return;
					} else {
						var oldDate = new Date(date);
						var oldDateNum = oldDate.valueOf();
						var newDateNum = getNewDateNum(oldDateNum, num);
						newDate = new Date(newDateNum);
					}
				} else {
					$.logUtil.save("增加天数时：非日期格式！");
					return;
				}
				var year = newDate.getFullYear();
				var month = newDate.getMonth() + 1;
				var day = newDate.getDate();
				return year + "-" + get2Length(month) + "-" + get2Length(day);

				function getNewDateNum(dateNum, num) {
					var number = num || 0;
					var newDateNum;
					newDateNum = dateNum + number * 24 * 60 * 60 * 1000;
					return newDateNum;
				}
			},
			// 判断输入的日期是否大于和等于指定的日期
			afterDate : function(inputDate, mDate) {
				mDate = mDate.replace(/\-/g, '/');
				var maxDate = new Date(mDate);
				var maxYear = maxDate.getFullYear();
				var maxMonth = maxDate.getMonth() + 1;
				var maxDay = maxDate.getDate();
				var maxStr = maxYear + "-" + get2Length(maxMonth) + "-"
						+ get2Length(maxDay);
				if (inputDate == maxStr)
					return true;
				var iDate = new Date(inputDate.replace(/\-/g, '/'));
				return (iDate >= maxDate);
			},
			/**
			 * 获取表单值
			 *
			 * @param formId
			 *            表单ID
			 */
			getFormValues : function(formId) {
				var params = new Object();
				$("form[id='" + formId + "'] input[name],select[name]").each(
						function() {
							var name = $(this).attr("name");
							var value = $(this).val();
							if (name != "" && value != "")
								params[name] = value;
						});
				return params;
			},
			/**
			 * 获取当前项目上下文,如：ebw
			 */
			getContextPath : function() {
				var context = $("#appName").val() || $("meta[name='appName']").attr("content");
				return context;
			},
			/**
			 * 增加年数，默认为增加一年
			 * @param date
			 */
			addYear : function(date, yearNumber) {
				var n = yearNumber || 1;
				var newDate;
				newDate = $.util.convertDate(date);
				var year = newDate.getFullYear() + n;
				var month = newDate.getMonth() + 1;
				var day = newDate.getDate();
				return year + "-" + get2Length(month) + "-" + get2Length(day);
			},
			/**
			 * 
			 */
			convertDate:function(date){
				var newDate;
				if (date instanceof Date) {
					newDate = date;
				} else if (typeof date == "string") {
					var pattern = new RegExp("-", "gi");
					date = date.replace(pattern, "/");
					if (/[0-9]{4}\/[0-9]{2}\/[0-9]{2}/.test(date)) {
						newDate = new Date(date);
					} else {
						return;
					}
				}
				return newDate;
			},
			/**
			 *年份差计算 
			 * 例：var diffYear =  $.util.getDiffYear("2008-11-25","2011-11-09"); //diffYear= 1
			 *     var diffYear =  $.util.getDiffYear("2010-10-25",new Date());
			 *     var diffYear =  $.util.getDiffYear("2010-10-25");  //等同于第二条
			 */
			getDiffYear : function(start, end) {
				end = end||new Date();
				var startDate = $.util.convertDate(start);
				var endDate = $.util.convertDate(end);
				
				var diffYear = 0;
				
				var startYear = startDate.getFullYear();
				var startMonth = (startDate.getMonth() + 1) * 1;
				var startDay = startDate.getDate();

				var endYear = endDate.getFullYear();
				var endMonth = (endDate.getMonth() + 1) * 1;
				var endDay = endDate.getDate();

				if (endYear - startYear > 0) {
					diffYear = endYear - startYear;
					if (endMonth - startMonth == 0) {
						if (endDay - startDay < 0) {
							diffYear-=0.5;
						}
						if (endDay - startDay > 0) {
							diffYear+=0.5;
						}
					} else if (endMonth - startMonth < 0) {
						diffYear-=0.5;
					} else  {
						diffYear+=0.5;
					}
				}
				return diffYear+"";

			},
			/**
			 * 监听输入框文字变化
			 * @param inputId 输入框ID
			 * @param text 要变化的文字,默认取值为输入框的内容
			 */
			changeInputText : function(inputId, text) {
				var input = $("#" + inputId);
				var t = text || input.get(0).defaultValue;
				input.css("color", "darkgray");
				input.val(t);
				input.focus( function() {
					if ($(this).val() ==t) {
						$(this).css("color", "");
						$(this).val("");
					}
				}).blur( function() {
					if ($(this).val() == "") {
						$(this).val(t);
						$(this).css("color", "darkgray");
					}else{
						$(this).css("color", "");
					}
				}).keyup(function(){
					if ($(this).val() == "") {
						$(this).val(t);
						$(this).css("color", "darkgray");
					}else{
						$(this).css("color", "");
					}
				});
			},
			/**
			 * 判断ID是否存在
			 */
			isExist:function(id){
				return document.getElementById(id);
			},
			replaceAll : function(oldString, oldC, targetC) {
				return oldString.replace(new RegExp(oldC, "g"), targetC);
			},
			isCNChar:function(str){
				var p = /^[\u4e00-\u9fa5]+$/;
				return p.test(str);
			},
			/**
			* 当证件类型为身份证时进行身份证号码的验证
			* @param selectId   证件类型下拉框ID
			* @param carInputId  身份证号码输入框ID
			*/
			 bindCheckIdCard:function(selectId, carInputId) {
			   $("#" + selectId).find("option").each(function() {
			       if ($(this).attr("selected")) {
			           var cardType = $(this).val();
			           if (cardType == "022001") {
			               $("#" + carInputId).addClass("checkIdCard");
			           }
			       }
			   });
			   $("#" + selectId).change(function() {
			       var cardType = $(this).val();
			       if (cardType == "022001") {
			           $("#" + carInputId).addClass("checkIdCard").valid();
			       } else {
			           $("#" + carInputId).removeClass("checkIdCard").valid();
			       }
			   });
			},
			toString:function(object){
				var str = "";
				object = object ||{};
				for(var p in object){
					str+=p+":"+object[p];
				}
				return str;
			}
		}
		
	})()
	
	/**
	 * 读取、写入cookie值
	 */
	$.cookie = ( function() {
		return {
			getCookie : function(cookie_name, decode) {
				decode = decode || true;
				var allcookies = document.cookie;
				var cookie_pos = allcookies.indexOf(cookie_name);

				var value = "";
				if (cookie_pos != -1) {
					cookie_pos += cookie_name.length + 1;
					var cookie_end = allcookies.indexOf(";", cookie_pos);
					if (cookie_end == -1) {
						cookie_end = allcookies.length;
					}//encodeURIComponent 防止 中文乱码
					value = allcookies.substring(cookie_pos, cookie_end);
					if (decode) {
						try {
							value = decodeURIComponent(value);
						} catch (e) {
							D.cookie.delCookie(cookie_name);
							return "";
						}
					}
				}
				return value;
			},
			setCookie : function(cookie_name, cookie_value) {
				document.cookie = cookie_name + "="
						+ encodeURIComponent(cookie_value) + "; path=/;";
			},
			setCookie_time : function(cookie_name, cookie_value, day) {
				var date = new Date(); // 获取当前时间
			var expireDays = parseInt(day) * 24 * 3600 * 1000; // 将date设置为n天以后的时间
			date.setTime(date.getTime() + expireDays);
			document.cookie = cookie_name + "=" + encodeURIComponent(cookie_value)
					+ "; expires=" + date.toGMTString() + "; path=/;";
		},
		delCookie : function(cookie_name) {
			var date = new Date();
			Y.cookie.setCookie_time(cookie_name,"0",date.getTime() - 1);
		}
		}
	})();
	
	
	$.logUtil = (function(){
		return {
			/**
			 * 在页面上保存日志,默认不显示，只在页面当中保存
			 * 可调用$.logUtil.show()显示日志信息;
			 * @param error 日志信息
			 */
			save : function(error) {
				var now = $.util.formatDate(new Date(), "yyyy-MM-dd HH:ss:mm");
				if (!document.getElementById("N_logUtil_save_info")) {
					$(
							"<div id='N_logUtil_save_info' style='display:none;background-color:white;width:500px;height:150px;"
									+ "z-index:100;position:fixed;top:75%;left:56%;font-size:12px;color:blue;overflow-y:auto;word-break:break-all;'>" +
											"</div>")
							.appendTo("body");
				}
				$("#N_logUtil_save_info").append("<font color='red'>"+now+"info:</font>" + error + "<br/><br/>");
				if ($.logUtil.defaults.debug) {
					$("#N_logUtil_save_info").show();
				}
				/*$("#Y_logUtil_info").click(function(){
					if($(this).attr("isshow")=="yes"){
						$("#Y_log_info_list").hide();
						$("#Y_logUtil_info").html("显示");
						$(this).attr("isshow","no");
					}else{
						$("#Y_log_info_list").show();
						$("#Y_logUtil_info").html("隐藏");
						$(this).attr("isshow","yes");
					}
				});*/
			},
			/**
			 * 车险
			 * 弹出错误信息，并保存错误信息
			 * @param error  错误信息
			 * @param alertFunction 保存错误后再调用用户自定义的alert方法
			 */
			alertFun : function(error, alertFunction) {
				var alertFun = alertFunction || null;
				var errorInfo = error;
				if(error.indexOf("log:") > -1){
					errorInfo = error.substring(0, error.indexOf("log:"));
				}
				
				var p = new RegExp("&","gi");
				errorInfo = errorInfo.replace(p,"");
				if (alertFun == null) {
//					alert(errorInfo);
					var tips = "<div id='tipsMessage'>";
					tips += "<div class='container_answer1' >";
					tips += "<span style='float: left;'><img src='../images/car_Spreadsheets/smail.gif'/*tpa=http://www.95590.cn/ebiz/res/images/car_Spreadsheets/smail.gif*/ width='60' height='60' /></span>";
					tips += "<span style='float: left; width:240px; margin-left:10px; margin-top:20px; font-size:14px;'>"+errorInfo+"</span>";
					tips += "</div>";
					tips += "</div>";
					if($("body").find("div[id=tipsMessage]").length>0){
						$("#tipsMessage").html(tips);
					}else{
						$("body").append(tips);
					}
//					$("#tipsMessage").html(tips);
					
					$('#tipsMessage').dialog({
						bgiframe : true,
						autoOpen : false,
						height : 200,
						width : 360,
						modal : true,
						resizable : false,
						title : "温馨提示",
						buttons : {
							"关闭" : function() {
								$(this).dialog("close");
							}
						}
					});
					$("#tipsMessage").dialog("open");
				} else {
					alertFun(errorInfo);
				}
				$.logUtil.save(error);
			},
			/**
			 * 弹出错误信息，并保存错误信息
			 * @param error  错误信息
			 * @param alertFunction 保存错误后再调用用户自定义的alert方法
			 */
			alert : function(error, alertFunction) {
				var alertFun = alertFunction || null;
				var errorInfo = error;
				if(error.indexOf("log:") > -1){
					errorInfo = error.substring(0, error.indexOf("log:"));
				}
				
				var p = new RegExp("&","gi");
				errorInfo = errorInfo.replace(p,"");
				if (alertFun == null) {
					alert(errorInfo);
				} else {
					alertFun(errorInfo);
				}
				$.logUtil.save(error);
			},
			/**
			 * 显示已出错的信息，之后会一直显示，直到调用隐藏方法
			 */
			show: function() {
				$("#N_logUtil_save_info").show();
				$.logUtil.defaults.debug = true;
			},
			/**
			 * 隐藏出错信息，之后会一直隐藏，直到调用显示方法
			 */
			hide: function() {
				$.logUtil.defaults.debug = false;
				$("#N_logUtil_save_info").hide();
			},
			clear : function() {
				$("#N_logUtil_save_info").html("");
			}
		};
	})()
	$.logUtil.defaults = {
		debug : false
	};
	/* 需要 jQuery.blockUI支持*/
	$.tip = (function() {
	    var object = {};
	    var oldObject = {};
	    var o = {
	        css: {
	            border: 'none',
	            padding: '15px',
	            backgroundColor: '#000',
	            '-webkit-border-radius': '10px',
	            '-moz-border-radius': '10px',
	            opacity: .5,
	            color: '#fff',
	            cursor:"default",
	            'font-size': "12px",
	            'font-family': "'宋体','微软雅黑','黑体','simsun'"
	        },
	        message: "正在处理，请稍候......"
	    };
	    return {
	        show: function(params) {
	    		oldObject = $.extend({},o);// 防止o对象被污染
	            object = $.extend(o, params || {});
	            o = oldObject;
	            $.blockUI(object);
	            },
	            hide: function() {
	            	 $.unblockUI(object);
	            },
	            getObject:function(){
	            	return object;
	            }
	        }
	    })();
	
})(jQuery);


/*******************************************************************************
 * BLOCK UI弹出框开始
 */
;
(function($) {
	if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
		alert('blockUI requires jQuery v1.2.3 or later!  You are using v' + $.fn.jquery);
		return;
	}
	$.fn._fadeIn = $.fn.fadeIn;
	var mode = document.documentMode || 0;
	var setExpr = $.browser.msie
			&& (($.browser.version < 8 && !mode) || mode < 8);
	var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent) && !mode;
	$.blockUI = function(opts) {
		install(window, opts);
	};
	$.unblockUI = function(opts) {
		remove(window, opts);
	};
	$.growlUI = function(title, message, timeout, onClose) {
		var $m = $('<div class="growlUI"></div>');
		if (title)
			$m.append('<h1>' + title + '</h1>');
		if (message)
			$m.append('<h2>' + message + '</h2>');
		if (timeout == undefined)
			timeout = 3000;
		$.blockUI( {
			message : $m,
			fadeIn : 700,
			fadeOut : 1000,
			centerY : false,
			timeout : timeout,
			showOverlay : false,
			onUnblock : onClose,
			css : $.blockUI.defaults.growlCSS
		});
	};
	$.fn.block = function(opts) {
		return this.unblock( {
			fadeOut : 0
		}).each(function() {
			if ($.css(this, 'position') == 'static')
				this.style.position = 'relative';
			if ($.browser.msie)
				this.style.zoom = 1;
			install(this, opts);
		});
	};
	$.fn.unblock = function(opts) {
		return this.each(function() {
			remove(this, opts);
		});
	};
	$.blockUI.version = 2.25;
	$.blockUI.defaults = {
		message : '<h1>Please wait...</h1>',
		title : null,
		draggable : true,
		theme : false,
		css : {
			padding : 0,
			margin : 0,
			width : '30%',
			top : '40%',
			left : '35%',
			textAlign : 'center',
			color : '#000',
			border : '3px solid #aaa',
			backgroundColor : '#fff',
			cursor : 'wait'
		},
		themedCSS : {
			width : '30%',
			top : '40%',
			left : '35%'
		},
		overlayCSS : {
			backgroundColor : '#000',
			opacity : 0.6,
			cursor : 'wait'
		},
		growlCSS : {
			width : '350px',
			top : '10px',
			left : '',
			right : '10px',
			border : 'none',
			padding : '5px',
			opacity : 0.6,
			cursor : null,
			color : '#fff',
			backgroundColor : '#000',
			'-webkit-border-radius' : '10px',
			'-moz-border-radius' : '10px'
		},
		iframeSrc : /^https/i.test(window.location.href || '') ? 'javascript:false'
				: 'about:blank',
		forceIframe : false,
		baseZ : 1000,
		centerX : true,
		centerY : true,
		allowBodyStretch : true,
		bindEvents : true,
		constrainTabKey : true,
		fadeIn : 200,
		fadeOut : 400,
		timeout : 0,
		showOverlay : true,
		focusInput : true,
		applyPlatformOpacityRules : true,
		onUnblock : null,
		quirksmodeOffsetHack : 4
	};
	var pageBlock = null;
	var pageBlockEls = [];
	function install(el, opts) {
		var full = (el == window);
		var msg = opts && opts.message !== undefined ? opts.message : undefined;
		opts = $.extend( {}, $.blockUI.defaults, opts || {});
		opts.overlayCSS = $.extend( {}, $.blockUI.defaults.overlayCSS,
				opts.overlayCSS || {});
		var css = $.extend( {}, $.blockUI.defaults.css, opts.css || {});
		var themedCSS = $.extend( {}, $.blockUI.defaults.themedCSS,
				opts.themedCSS || {});
		msg = msg === undefined ? opts.message : msg;
		if (full && pageBlock)
			remove(window, {
				fadeOut : 0
			});
		if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
			var node = msg.jquery ? msg[0] : msg;
			var data = {};
			$(el).data('blockUI.history', data);
			data.el = node;
			data.parent = node.parentNode;
			data.display = node.style.display;
			data.position = node.style.position;
			if (data.parent)
				data.parent.removeChild(node);
		}
		var z = opts.baseZ;
		var lyr1 = ($.browser.msie || opts.forceIframe) ? $('<iframe class="blockUI" style="z-index:'
				+ (z++)
				+ ';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'
				+ opts.iframeSrc + '"></iframe>')
				: $('<div class="blockUI" style="display:none"></div>');
		var lyr2 = $('<div class="blockUI blockOverlay" style="z-index:' + (z++) + ';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
		var lyr3;
		if (opts.theme && full) {
			var s = '<div class="blockUI blockMsg blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'
					+ z
					+ ';display:none;position:fixed">'
					+ '<div class="ui-widget-header ui-dialog-titlebar blockTitle">'
					+ (opts.title || '&nbsp;')
					+ '</div>'
					+ '<div class="ui-widget-content ui-dialog-content"></div>'
					+ '</div>';
			lyr3 = $(s);
		} else {
			lyr3 = full ? $('<div class="blockUI blockMsg blockPage" style="z-index:' + z + ';display:none;position:fixed"></div>')
					: $('<div class="blockUI blockMsg blockElement" style="z-index:' + z + ';display:none;position:absolute"></div>');
		}
		if (msg) {
			if (opts.theme) {
				lyr3.css(themedCSS);
				lyr3.addClass('ui-widget-content');
			} else
				lyr3.css(css);
		}
		if (!opts.applyPlatformOpacityRules
				|| !($.browser.mozilla && /Linux/.test(navigator.platform)))
			lyr2.css(opts.overlayCSS);
		lyr2.css('position', full ? 'fixed' : 'absolute');
		if ($.browser.msie || opts.forceIframe)
			lyr1.css('opacity', 0.0);
		$( [ lyr1[0], lyr2[0], lyr3[0] ]).appendTo(full ? 'body' : el);
		if (opts.theme && opts.draggable && $.fn.draggable) {
			lyr3.draggable( {
				handle : '.ui-dialog-titlebar',
				cancel : 'li'
			});
		}
		var expr = setExpr
				&& (!$.boxModel || $('object,embed', full ? null : el).length > 0);
		if (ie6 || expr) {
			if (full && opts.allowBodyStretch && $.boxModel)
				$('html,body').css('height');
			if ((ie6 || !$.boxModel) && !full) {
				var t = sz(el, 'borderTopWidth'), l = sz(el, 'borderLeftWidth');
				var fixT = t ? '(0 - ' + t + ')' : 0;
				var fixL = l ? '(0 - ' + l + ')' : 0;
			}
			$
					.each(
							[ lyr1, lyr2, lyr3 ],
							function(i, o) {
								var s = o[0].style;
								s.position = 'absolute';
								if (i < 2) {
									full ? s
											.setExpression(
													'height',
													'Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:' + opts.quirksmodeOffsetHack + ') + "px"')
											: s
													.setExpression('height',
															'this.parentNode.offsetHeight + "px"');
									full ? s
											.setExpression(
													'width',
													'jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"')
											: s
													.setExpression('width',
															'this.parentNode.offsetWidth + "px"');
									if (fixL)
										s.setExpression('left', fixL);
									if (fixT)
										s.setExpression('top', fixT);
								} else if (opts.centerY) {
									if (full)
										s
												.setExpression(
														'top',
														'(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
									s.marginTop = 0;
								} else if (!opts.centerY && full) {
									var top = (opts.css && opts.css.top) ? parseInt(opts.css.top)
											: 0;
									var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + ' + top + ') + "px"';
									s.setExpression('top', expression);
								}
							});
		}
		if (msg) {
			if (opts.theme)
				lyr3.find('.ui-widget-content').append(msg);
			else
				lyr3.append(msg);
			if (msg.jquery || msg.nodeType)
				$(msg).show();
		}
		if (($.browser.msie || opts.forceIframe) && opts.showOverlay)
			lyr1.show();
		if (opts.fadeIn) {
			if (opts.showOverlay)
				lyr2._fadeIn(opts.fadeIn);
			if (msg)
				lyr3.fadeIn(opts.fadeIn);
		} else {
			if (opts.showOverlay)
				lyr2.show();
			if (msg)
				lyr3.show();
		}
		bind(1, el, opts);
		if (full) {
			pageBlock = lyr3[0];
			pageBlockEls = $(':input:enabled:visible', pageBlock);
			if (opts.focusInput)
				setTimeout(focus, 20);
		} else
			center(lyr3[0], opts.centerX, opts.centerY);
		if (opts.timeout) {
			var to = setTimeout(function() {
				full ? $.unblockUI(opts) : $(el).unblock(opts);
			}, opts.timeout);
			$(el).data('blockUI.timeout', to);
		}
	}
	;
	function remove(el, opts) {
		var full = (el == window);
		var $el = $(el);
		var data = $el.data('blockUI.history');
		var to = $el.data('blockUI.timeout');
		if (to) {
			clearTimeout(to);
			$el.removeData('blockUI.timeout');
		}
		opts = $.extend( {}, $.blockUI.defaults, opts || {});
		bind(0, el, opts);
		var els;
		if (full)
			els = $('body').children().filter('.blockUI')
					.add('body > .blockUI');
		else
			els = $('.blockUI', el);
		if (full)
			pageBlock = pageBlockEls = null;
		if (opts.fadeOut) {
			els.fadeOut(opts.fadeOut);
			setTimeout(function() {
				reset(els, data, opts, el);
			}, opts.fadeOut);
		} else
			reset(els, data, opts, el);
	}
	;
	function reset(els, data, opts, el) {
		els.each(function(i, o) {
			if (this.parentNode)
				this.parentNode.removeChild(this);
		});
		if (data && data.el) {
			data.el.style.display = data.display;
			data.el.style.position = data.position;
			if (data.parent)
				data.parent.appendChild(data.el);
			$(data.el).removeData('blockUI.history');
		}
		if (typeof opts.onUnblock == 'function')
			opts.onUnblock(el, opts);
	}
	;
	function bind(b, el, opts) {
		var full = el == window, $el = $(el);
		if (!b
				&& (full && !pageBlock || !full
						&& !$el.data('blockUI.isBlocked')))
			return;
		if (!full)
			$el.data('blockUI.isBlocked', b);
		if (!opts.bindEvents || (b && !opts.showOverlay))
			return;
		var events = 'mousedown mouseup keydown keypress';
		b ? $(document).bind(events, opts, handler) : $(document).unbind(
				events, handler);
	}
	;
	function handler(e) {
		if (e.keyCode && e.keyCode == 9) {
			if (pageBlock && e.data.constrainTabKey) {
				var els = pageBlockEls;
				var fwd = !e.shiftKey && e.target == els[els.length - 1];
				var back = e.shiftKey && e.target == els[0];
				if (fwd || back) {
					setTimeout(function() {
						focus(back)
					}, 10);
					return false;
				}
			}
		}
		if ($(e.target).parents('div.blockMsg').length > 0)
			return true;
		return $(e.target).parents().children().filter('div.blockUI').length == 0;
	}
	;
	function focus(back) {
		if (!pageBlockEls)
			return;
		var e = pageBlockEls[back === true ? pageBlockEls.length - 1 : 0];
		if (e)
			e.focus();
	}
	;
	function center(el, x, y) {
		var p = el.parentNode, s = el.style;
		var l = ((p.offsetWidth - el.offsetWidth) / 2)
				- sz(p, 'borderLeftWidth');
		var t = ((p.offsetHeight - el.offsetHeight) / 2)
				- sz(p, 'borderTopWidth');
		if (x)
			s.left = l > 0 ? (l + 'px') : '0';
		if (y)
			s.top = t > 0 ? (t + 'px') : '0';
	}
	;
	function sz(el, p) {
		return parseInt($.css(el, p)) || 0;
	}
	;
})(jQuery);
/*******************************************************************************
 * BLOCK UI弹出框结束
 */